import {
  Body,
  Controller,
  Get,
  Param,
  Post,
  Query,
  SerializeOptions,
} from '@nestjs/common';
import { BookingService } from './booking.service';
import { CreateBookingDto, ListQueryDto } from './dtos/index.dto';
import { RequireLogin } from 'src/decorators/custom-decorator';

@Controller('booking')
export class BookingController {
  constructor(private readonly bookingService: BookingService) {}

  @SerializeOptions({ groups: ['booking-query'] })
  @Get('list')
  @RequireLogin()
  async list(@Query() query: ListQueryDto) {
    return await this.bookingService.list(query);
  }

  @Post()
  @RequireLogin()
  async create(@Body() data: CreateBookingDto) {
    return await this.bookingService.create(data);
  }

  @SerializeOptions({ groups: ['booking-detail'] })
  @Get(':id')
  @RequireLogin()
  async detail(@Param('id') id: number) {
    return await this.bookingService.detail(+id);
  }

  @Get('apply/:id')
  async apply(@Param('id') id: number) {
    return await this.bookingService.apply(id);
  }

  @Get('reject/:id')
  @RequireLogin()
  async reject(@Param('id') id: number) {
    return await this.bookingService.reject(id);
  }

  @Get('unbind/:id')
  @RequireLogin()
  async unbind(@Param('id') id: number) {
    return await this.bookingService.unbind(id);
  }

  @Get('urge/:id')
  @RequireLogin()
  async urge(@Param('id') id: number) {
    return await this.bookingService.urge(id);
  }
}
